package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.discovery.bean.SearchAuthorResponse;
import com.rongshu.view.userInfo.iview.AttentionView;

import rx.Subscriber;

public class AttentionPresenter extends BasePresenter<AttentionView>{

    public AttentionPresenter(Context context) {
        super(context);
    }

    /**
     * 获取我的主页 我的关注 1，我的粉丝 2 ,我的黑名单 3
     */
    public void getSetUserRelationships(int user_id, int type, int page, int pageSize, String sign) {
        RetorfitService.getSetUserRelationships(user_id, type, page, pageSize, sign)
                .subscribe(new Subscriber<SearchAuthorResponse>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(SearchAuthorResponse response) {
                        if (getView() != null) {
                            getView().onAttentionUser(response);
                        }
                    }
                });
    }

    /**
     * 取消关注
     */
    public void cancelConcernWith(int user_id, int contribute_id, int user_id_to, String sign) {
        RetorfitService.cancelConcernWith(user_id, contribute_id, user_id_to, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean iNetBean) {
                        if (getView() != null) {
                            getView().onCancleConcern(iNetBean);
                        }
                    }
                });
    }
}
